package com.rd.student.ruanjian.class4.zhouzihe.day18;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class TestInputStream {
    public static void main(String[] args) throws IOException {
        testRead1();
    }

    public static void testRead() throws IOException {
        InputStream is = new FileInputStream("stream.txt");
        while (true) {
            int len = is.read();
            if (len == -1) break;

            byte[] arr = new byte[1];
            arr[0] = (byte) len;
            System.out.print(new String(arr));
        }
        is.close();
    }

    public static void testRead1() throws IOException {
        InputStream is = new FileInputStream("stream.txt");
        while (true) {
            byte[] arr = new byte[1024];
            int len = is.read(arr);
            if (len == -1) break;
            String content = new String(arr);
            System.out.print(content);
        }
        is.close();

    }

}
